package com.bookyourtrek.action;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Map;

import com.bookyourtrek.model.ImageModel;
import com.bookyourtrek.model.ImagePojo;
import com.bookyourtrek.model.TicketModel;
import com.bookyourtrek.model.TicketPojo;
import com.bookyourtrek.model.TrekModel;
import com.bookyourtrek.model.TrekPojo;
import com.bookyourtrek.util.RuntimeSettings;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class ConfirmTrekAction extends ActionSupport{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	ArrayList<TrekPojo> trekpojo = new ArrayList<TrekPojo>();
	public ArrayList<TrekPojo> getTrekpojo() {
		return trekpojo;
	}

	public void setTrekpojo(ArrayList<TrekPojo> trekpojo) {
		this.trekpojo = trekpojo;
	}

	public ArrayList<TicketPojo> getTicketpojo() {
		return ticketpojo;
	}

	public void setTicketpojo(ArrayList<TicketPojo> ticketpojo) {
		this.ticketpojo = ticketpojo;
	}

	public ArrayList<ImagePojo> getImagepojo() {
		return imagepojo;
	}

	public void setImagepojo(ArrayList<ImagePojo> imagepojo) {
		this.imagepojo = imagepojo;
	}

	ArrayList<TicketPojo> ticketpojo = new ArrayList<TicketPojo>();
	ArrayList<ImagePojo> imagepojo = new ArrayList<ImagePojo>();
	
	/**
	 * function to get trek details
	 * @author ananda
	 * @return SUCCESS/INPUT
	 */
	@SuppressWarnings("rawtypes")
	public String confirmtrek() {
		TrekModel trekmodel = new TrekModel();
		TicketModel ticketmodel = new TicketModel();
		ImageModel imagemodel = new ImageModel();
		
		//get the trek details
		Map sess=ActionContext.getContext().getSession();
		//validation
		
				if(sess.get("trekid") == null) {
					return "home";
				}
		BigInteger trekid = (BigInteger) sess.get("trekid");
		trekpojo = trekmodel.gettrekdetails(trekid);
		//System.out.println(trekpojo.get(0).getTrekplan());
		//get images
		imagepojo = imagemodel.getimages(trekid);
		
		//get ticket
		ticketpojo = ticketmodel.getticket(trekid, RuntimeSettings.EVENTTREKKING.toString());
		
		return SUCCESS;
	}
}
